
$(function() {
	var token = localStorage.phone;
	var school_id = localStorage.school_id;
	$.ajax({
		url: "https://newapp.icandrive.cn/api/schoolInfo.php",
		data: {
			token: token,
			school_id: school_id
		},
		dataType: 'json',
		type: 'post',
		success: function(data) {
			if(data.status) {
				$('#tell').click(function() {
					window.location.href = 'tel:' + data.data.school_phone;
				});
				localStorage.gps_jj = data.data.gps_j;
				localStorage.gps_ww = data.data.gps_w;
				localStorage.school_address = data.data.school_address;
				localStorage.man_phone = data.data.man_phone;

				$('#school_name').html(data.data.school_name);
				$('#school_address').html(data.data.school_address);
				$('#school_man').html(data.data.school_man);
				$('#man_phone').html('联系电话:' + data.data.man_phone);
				if($.trim(data.data.school_place1) != '') {
					$('#chose').append("<label for='input_learn_2'>一费制<input id='input_learn_2' type='radio' value='one' name='sign_type' disabled /><i></i></label>")
					$('#school_place').html("<del>￥" + data.data.school_place1 + "</del>￥" + data.data.school_place2);
				} else {
					$('#school_place').html("￥" + data.data.school_place2);
				}

				$('#chose input').prop('disabled', false);
				$('.qw').prop('src', data.data.school_img2);
				var place = data.data.school_place2;
				$("#chose label").click(function() {
					if($(this).find('input').val() == 'one') {
						$('#school_place').html("<del>￥" + data.data.school_place2 + "</del>￥" + data.data.school_place1);
						place = data.data.school_place1;
					} else {
						$('#school_place').html("<del>￥" + data.data.school_place1 + "</del>￥" + data.data.school_place2);
						place = data.data.school_place2;
					}
				});
				$("input[type='button']").click(function() {

					localStorage.place = place;
					var sign_type = '';
					$("input[name='sign_type']").each(function() {
						if($(this).prop('checked')) {
							sign_type = $(this).val();
						}
					});
					var sign_type_name = '一费制';
					if(sign_type == 'rntime') {
						sign_type_name = '计时学车';
					}

					localStorage.sign_type = sign_type;
					localStorage.sign_type_name = sign_type_name;

					/*window.location.href='../payment/02/school_pay.html';*/
					window.location.href = '../enlist_button/enlist_button.html'
				})
			} else {
				layer.msg("数据获取失败");
			}
		},
		error: function() {
			layer.msg('系统繁忙', function() {
				history.go(0)
			}, 1000);
		}
	});

	/*点击地址跳转到地图*/
	$(".address").click(function() {
		window.location.href = "../address/distence.html";
	});

})

/*监听手机返回按键*/
function return_keybord() {
	document.addEventListener("plusready", function() {
		// 注册返回按键事件
		plus.key.addEventListener('backbutton', function() {
			window.history.back();
		}, false);
		//此处false代表不退出页面，如果为true回退到上一个一面
	});
}
